function createLinks() {
	
	
	//Pop up Window for Get Off the Internet
	$$('.popup').each(function(link) {
		
		link.observe ('click', function(e) {
			var url = link.getAttribute('href');
			var name = 'GetOffTheInternet';
			var width=1003;
			var height=670;
			var scrollbars='no';
			var resizable='no';
			var atts='width='+width+',height='+height+',scrollbars='+scrollbars+',resizable='+resizable;
			window.open(url, name, atts);
			e.stop();
		
		});
	
	});
	
	
	//Create Links for scrolling
	$$('.section').each(function(link) { 
	
		link.observe ('click', function(e) {
		
			Event.stopObserving(window, 'scroll', checkPos);
			
			var destination = link.href.split('#').last();
									
			Effect.ScrollTo(destination, { duration: 1.5, afterFinish: scrollEnd }); 
						
			e.stop();
		});
	
	});


	//Open bigger images
	$$('.stb').each(function(link) { 
	
		link.observe ('click', function(e) { 
						
			link.toggleClassName('stb');
			
			e.stop();
		});
	
	});
	

}


function checkPos() {	
		
	$('content').select('div').each( function(div, index) {
		
		 if (div.viewportOffset().top <= 200 & div.viewportOffset().top > -100 & div.identify() != location.hash.substr(1) ) {
		 			 	
		 	$$('.sel').each( function(sel) {
		 	
		 		sel.removeClassName('sel');
		 	
		 	});

		 	$('menu').down('a.section', index).addClassName('sel');
		 	
		}
		
	});
}

function scrollEnd() {
	
	checkPos();
	
	location.hash = $$('.sel')[0].href.split('#').last();
	
	scrollObserver();
}

function scrollObserver() {
	Event.observe(window, 'scroll', checkPos);
}


document.observe("dom:loaded", function(){

	checkPos();
	createLinks();
	scrollObserver();
	
});




